package com.alibaba.yinan.domain.task.event;

import com.alibaba.yinan.domain.task.Task;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @ClassName TaskEventPublisher
 * @Author mengke
 * @create 2025/8/4 02:31
 * @Description
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class TaskEventPublisher {

    private final ApplicationEventPublisher publisher;

    public void publish(Task task, String eventType) {
        log.info("开始发布任务事件，任务ID：{},任务状态：{}", task.getId(), task.getStatus());
        publisher.publishEvent(new TaskDomainEvent(task, eventType));
    }
}
